/**
 * 
 */
package edu.uc.ui;

import java.util.ArrayList;

import android.app.AlertDialog;
import android.content.Context;
import android.graphics.drawable.Drawable;

import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.OverlayItem;

/**
 * class HelloItemizedOverlay
 * 
 * @author Jimmy
 *
 *this class handles the itemized overlays
 */
@SuppressWarnings("rawtypes")
public class HelloItemizedOverlay extends ItemizedOverlay {

	// an OverlayItem ArrayList, in which you'll put each of the OverlayItem objects you want on the map
	private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
	private Context mContext;
	
	
	/**
	 * method HelloItemizedOvedrlay
	 * 
	 * @param arg0
	 * 
	 */
	public HelloItemizedOverlay(Drawable arg0) {
		super(arg0);
		// TODO Auto-generated constructor stub
	}

	/**
	 * method HelloItemizedOverlay
	 * 
	 * @param defaultMarker
	 * @param context
	 * This passes the defaultMarker up to the default constructor to bound its coordinates 
	 * and then initializes mContext with the given Context. 
	 */
	public HelloItemizedOverlay(Drawable defaultMarker, Context context) {
		  super(boundCenterBottom(defaultMarker));
		  mContext = context;
		}
	
	
	/* (non-Javadoc)
	 * @see com.google.android.maps.ItemizedOverlay#createItem(int)
	 */
	@Override
	protected OverlayItem createItem(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	/* (non-Javadoc)
	 * @see com.google.android.maps.ItemizedOverlay#size()
	 */
	@Override
	public int size() {
		// TODO Auto-generated method stub
		return 0;
	}
	
	
	/**
	 * method addOverlay
	 * 
	 * Each time you add a new OverlayItem to the ArrayList, you must call populate() for the ItemizedOverlay, 
	 * which will read each of the OverlayItem objects and prepare them to be drawn. 
	 * @param overlay
	 */
	public void addOverlay(OverlayItem overlay) {
	    mOverlays.add(overlay);
	    populate();
	}
	
	
	/* (non-Javadoc)
	 * override the onTap() callback method, which will handle the event when an item is tapped by the user
	 */
	@Override
	protected boolean onTap(int index) {
	  OverlayItem item = mOverlays.get(index);
	  AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
	  dialog.setTitle(item.getTitle());
	  dialog.setMessage(item.getSnippet());
	  dialog.show();
	  return true;
	}
	
	
	

}
